package design.patterns.factorymode.factory;

import design.patterns.factorymode.service.BMW;
import design.patterns.factorymode.service.Benz;
import design.patterns.factorymode.api.CarFactoryInterface;

/**
 * 汽车制造工厂类
 * @author ： cww
 * @date : 2018/7/2
 */
public class Factory {

    /**
     * 根据传入的类型来创建对象
     * @param key
     * @return
     */
    public CarFactoryInterface getCar(String key){
        if ("Benz".equals(key)){
            return new Benz();
        }else if ("BMW".equals(key)){
            BMW bmw = new BMW();
            return new BMW();
        }else {
            return null;
        }
    }
}
